package wechat.rcv.controller

import com.shrcl.engineerprocess.domain.CertificationNotification
import com.shrcl.engineerprocess.domain.CorpWeChatUserDAO
import com.shrcl.engineerprocess.domain.EngineerProjectInitNotification
import com.shrcl.engineerprocess.domain.Notification
import com.shrcl.engineerprocess.domain.NotificationCriteria
import com.shrcl.engineerprocess.domain.TrainingNotification
import edu.fudan.mylang.pf.IObjectFactory
import java.text.SimpleDateFormat
import java.util.Collection
import org.apache.log4j.Logger
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Controller
import org.springframework.transaction.annotation.Transactional
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import wechat.app.UserID
import java.util.Date
import java.util.ArrayList
import wechat.rcv.RcvToken

@Controller
@Transactional
class GetMyList {

	final static Logger logger = Logger.getLogger(typeof(GetMyList).getName());

	@Autowired IObjectFactory entities;
	@Autowired CorpWeChatUserDAO corpWeChatUserDAO

	@RequestMapping("/mylist")
	def String process(
		@RequestParam(value="d2387fdefg3782", defaultValue="") String wechatid_rypt,
		@RequestParam(value="dh28rfr43gh", defaultValue="") String state,
		Model model
	) {
		logger.info('=========>GetMyList.processs<============')
		logger.info('=========>GetMyList.wechatid_rypt<============'+wechatid_rypt)
		var hpage = 'error'
//		var userid = UserID::getUserId(code)
		var wechatid = RcvToken.getWxcpt().decrypt(wechatid_rypt);
		logger.info('=========>GetMyList.wechatid<============'+wechatid)
		logger.info('=========>GetMyList.state<============'+state)
//		val receiver = corpWeChatUserDAO.findWeChatUser(userid)?.engineer.asNotifyReceiver
//		
//		val c = (entities.createQueryCriteria(typeof(NotificationCriteria))=>[
//			it.receiver = receiver
//			it.^start = 0
//			it.^limit = 4
//		])

		
		model.addAttribute("wechatid",wechatid);
		
		if (state == '101') hpage = "mynotification"
		else if (state == '100') hpage = "myworkorder"
	}

}

